package com.ch.playandroid.adapter

import com.alibaba.android.arouter.launcher.ARouter
import com.ch.common.base.adapter.BaseRecycleAdapter
import com.ch.common.constant.ConstantValue
import com.ch.playandroid.R
import com.ch.playandroid.bean.DataBean
import com.ch.playandroid.databinding.ArticleItemLayoutBinding

/**
 * databinding写Recycle写法，太爽了----对应（首页--文章列表）
 *
 * */

class ArticleBindAdapter(private val dataList: List<DataBean>, mBdId: Int) :
    BaseRecycleAdapter<DataBean, ArticleItemLayoutBinding>(dataList, mBdId) {
    override fun getLayoutId(): Int {
        return R.layout.article_item_layout
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        super.onBindViewHolder(holder, position)
        holder.itemView.setOnClickListener {
            ARouter.getInstance().build(ConstantValue.PATH_WEB_VIEW)
                .withString(ConstantValue.ACTION_KEY_TITLE, dataList[position].title)
                .withString(ConstantValue.ACTION_KEY_URL, dataList[position].link)
                .navigation()
        }
    }
}